# 相对路径 参照物
# 参照物: 当前执行脚本所在的目录
# 'demo/hahaha.txt' == './demo/hahaha.txt'

# 绝对路径
# '某某下的/某某下的/某某文件.后缀'
# C:\Users\年轻人\Desktop\python_work\day14\demo
# hahaha.txt : C:\Users\年轻人\Desktop\python_work\day14\demo

# 桌面上的文件:desktop_demo.txt
# 绝对路径
# C:\Users\年轻人\Desktop
import os
with open(r'C:\Users\年轻人\Desktop\hahaha.txt', 'w', encoding='utf8') as f:
    f.write('hello,wuhan')

# os 模式下下面有路径相关的处理方法:
import os
# os.path.dirname() # 获取资源所在的目录
print(__file__)
desktop__path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
# filename_path - desktop_path + '\\' + 'hahaha.txt'
# os.path.join(xx, xx)
filename_path = os.path.join(desktop__path, 'hahaha.txt')
print(filename_path)
